<template>
  <u-container-layout>
    <zlrt-table :p="ctx">
      <template #before>
         <zlrt-search :p="ctx"></zlrt-search>
         <div style="margin-bottom: 10px;">
          <el-button type="danger" v-hasPermit="['core:dict:del']" icon="Delete"
            :disabled="!ctx.selected.length" @click="ctx.batchDelete()">
            批量删除
          </el-button>
          <span style="float:right">
            <el-button type="success" v-hasPermit="['core:dict:list']" :loading="ctx.exportLoading" icon="Download"
              @click="ctx.export()">
              导出
            </el-button>
            <el-button type="primary" v-hasPermit="['core:dict:save']" icon="Plus" @click="ctx.showEdit()">
              添加
            </el-button>
          </span>
        </div>
      </template>
      <template #dictType="scope">
        <router-link :to="'/system/dict-data/' + scope.row.id" class="link-type">
          <span>{{ scope.row.dictType }}</span>
        </router-link>
      </template>
      <template #disabled="scope">
        <el-switch
          v-model="scope.row.disabled"
          :active-value="false"
          :inactive-value="true"
          @change="ctx.other.statusChanged(scope.row)"
        />
      </template>
      <template v-slot:operation="scope">
        <el-button type="primary"  v-hasPermit="['core:dict:save']" link size="small" icon="Edit" @click="ctx.showEdit(scope.row)">
          编辑
        </el-button>
        <el-button  type="danger"  v-hasPermit="['core:dict:del']" link size="small" icon="Delete" @click="ctx.del(scope.row.id)">
          删除
        </el-button>
      </template>
      <template #after>
        <el-dialog v-model="ctx.editVisible" :title="ctx.editAction + ctx.title" width="600px"
            append-to-body :close-on-click-modal="false" @close="ctx.closeEdit()">
            <el-form :ref="(e) => ctx.formRef = e" :model="ctx.editData" :rules="ctx.rules"
              v-loading="ctx.editLoading" label-width="120px" class="demo-ruleForm">
               <el-form-item label="字典名称" prop="dictName">
                <el-input v-model="ctx.editData.dictName" placeholder="请输入字典名称"/>
              </el-form-item>
              <el-form-item label="字典类型" prop="dictType">
                <el-input v-model="ctx.editData.dictType" placeholder="请输入字典类型"/>
              </el-form-item>
              <el-form-item label="状态" prop="disabled">
                <el-select v-model="ctx.editData.disabled" placeholder="请选择状态">
                  <el-option v-for="ite in disabledOptions" :key="ite.value" :label="ite.label" :value="ite.value" />
                </el-select>
              </el-form-item>
            </el-form>
            <template #footer>
              <span class="dialog-footer">
                <el-button @click="ctx.editVisible = false">取消</el-button>
                <el-button type="primary" @click="ctx.save()">确定</el-button>
              </span>
            </template>
          </el-dialog>
      </template>
    </zlrt-table>
  </u-container-layout>
</template>

<script lang="ts" src="./dict" />

<style lang="scss" scoped>
</style>
